export const saveLogin = (ticket) => {
  // 缓存到本地防止刷新ticket 丢失
  try {
    uni.setStorageSync('ticket', ticket);
  } catch (err) {
    throw new Error('ticket 缓存失败');
  }
};

// 清空登录态
export const cleanLogin = () => {
  // 缓存到本地防止刷新ticket 丢失
  try {
    uni.setStorageSync('ticket', '');
  } catch (err) {
    throw new Error('ticket 清除失败');
  }
};

// 获取ticket
export const getTicket = () => {
   try {
      return uni.getStorageSync('ticket');
    } catch {
      return '';
    }
};

// 检查是否登录
export const checkLogin = () => {
  return !!getTicket();
};